﻿using System.Collections.Generic;
using System.Linq;
using Melee.DataContract.Views;
using Melee.Infrastructure.Configuration;
using Melee.Models.Entity;

namespace Melee.DataContract.Extension
{
    public static class DuplicateExtensionMethod
    {
        public static IEnumerable<DuplicateView> ConvertToDuplicateView(this IEnumerable<Duplicate> duplicates)
        {
            return duplicates.Select(d => new DuplicateView
            {
                Id = d.Id,
                Name = d.Name,
                X = d.StartingPoint.X * ApplicationSettingsFactory.ApplicationSettings.PointLength,
                Y = d.StartingPoint.Y * ApplicationSettingsFactory.ApplicationSettings.PointLength,
                Width = d.Width * ApplicationSettingsFactory.ApplicationSettings.PointLength,
                Height = d.Height * ApplicationSettingsFactory.ApplicationSettings.PointLength
            });
        }
    }
}
